//
//  ThorServiceManager.m
//  ThorWebView_Example
//
//  Created by panfei mao on 2019/1/15.
//  Copyright © 2019 panfei mao. All rights reserved.
//

#import "ThorServiceManager.h"
#import "ThorUserCheckApi.h"

@implementation ThorServiceManager

- (void)thor_userCheckWithUserPhone:(NSString *)userPhone userId:(NSString *)userId channel:(NSString *)channel{
    ThorUserCheckApi *userCheckApi = [[ThorUserCheckApi alloc] initWithUserPhone:userPhone userId:userId channel:channel];
    [userCheckApi requestWithSuccess:^(NSDictionary *responseDict) {
        NSLog(@"responseDict = %@",responseDict);
        if (responseDict) {
            NSDictionary *data = responseDict[@"data"];
            NSString *url = [data[@"url"] description];
            NSString *code = [responseDict[@"code"] description];
            if ([code isEqualToString:@"0"]) {
                if (self.delegate && [self.delegate respondsToSelector:@selector(thor_userCheckSuccess:)]) {
                    [self.delegate thor_userCheckSuccess:url];
                }
            } else {
                if (self.delegate && [self.delegate respondsToSelector:@selector(thor_dataFailure)]) {
                    [self.delegate thor_dataFailure];
                }
            }
        }
    } failure:^(__kindof YTKBaseRequest *request) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(thor_dataFailure)]) {
            [self.delegate thor_dataFailure];
        }
    }];
}

@end
